# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=tpaste
pkgver=0.8
pkgrel=0
pkgdesc="Helper script to paste things to https://tpaste.us"
url="https://tpaste.us"
arch="noarch"
license="GPL-2.0-only"
depends="curl"
subpackages="dpaste ix"
options="!check"
builddir="$srcdir"

package() {
	mkdir -p "$pkgdir"/usr/bin
	printf "#!/bin/sh\n\nexec curl -sSF 'tpaste=<-' $url" > \
		"$pkgdir"/usr/bin/tpaste
	chmod 755 "$pkgdir"/usr/bin/tpaste
}

dpaste() {
	url="https://dpaste.com"
	pkgdesc="Helper script to paste things to $url"

	printf > dpaste -- '%s\n' \
		'#!/bin/sh' '' \
		"exec curl -sSF 'content=<-' "$url/api/v2/" | sed -e 's/\$/.txt/'"
	install -Dm 0755 dpaste "$subpkgdir/usr/bin/dpaste"
}

ix() {
	url="https://ix.io"
	pkgdesc="Helper script to paste things to $url"
	mkdir -p "$subpkgdir"/usr/bin
	printf "#!/bin/sh\n\nexec curl -sSF f:1='<-' $url/" > \
		 "$subpkgdir"/usr/bin/ix
	chmod 755 "$subpkgdir"/usr/bin/ix
}
